let http = require("http");
let url = require("url");
let queryString = require("querystring");
let util = require("util");
let port = 9999;

function start(){
    http.createServer(function(req, res){
        console.log("Request recieved: " + new Date().getTime());

        let post = "";

        req.on("data", function(chunk){
            post += chunk;
        });

        req.on("end", function(){
            let obj = queryString.parse(post);
            res.writeHead(200, {"Content-Type" : "text/html"});
            res.end(util.inspect(obj));
        });
    }).listen(port);

    console.log("server start: localhost:" + port);
}

exports.start = start;